package com.taoyibao.hongcanting.dialog;

import android.annotation.SuppressLint;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;

import com.taoyibao.hongcanting.R;
import com.taoyibao.hongcanting.widget.WheelView;

import java.util.ArrayList;

/**
 * @author TangAnna
 * @description: 选择性别弹窗
 * @date :${DATA} 17:11
 */
@SuppressLint("ValidFragment")
public class DialogChooseGender extends BaseFragmentDialog implements View.OnClickListener {
    private WheelView mWheelView;
    /**
     * 完成按钮
     */
    private TextView mTvConfirm;
    private ArrayList<String> mData = new ArrayList<>();
    private DialogGrnderInterface mDialogGrnderInterface;

    public DialogChooseGender(DialogGrnderInterface dialogGrnderInterface) {
        mDialogGrnderInterface = dialogGrnderInterface;
    }

    @Override
    public int bindView() {
        return R.layout.dialog_choose_gender;
    }

    @Override
    public void initView(View view) {
        super.initView(view);
        mWheelView = view.findViewById(R.id.wv_dialogChooseGender_gender);
        mTvConfirm = view.findViewById(R.id.tv_dialogChooseGender_confirm);
    }

    @Override
    public void initData() {
        super.initData();
        mData.add("男");
        mData.add("女");
    }

    @Override
    public void setData() {
        super.setData();
        mWheelView.setData(mData);
        mWheelView.setDefault(0);
    }

    @Override
    public void setListener(View view) {
        super.setListener(view);
        mTvConfirm.setOnClickListener(this);

    }

    @Override
    protected int setAnimation() {
        return 0;
    }

    @Override
    protected int setGravity() {
        return Gravity.BOTTOM;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_dialogChooseGender_confirm://完成
                if (mDialogGrnderInterface != null && !TextUtils.isEmpty(mWheelView.getSelectedText())) {
                    mDialogGrnderInterface.onGrnderResult(mWheelView.getSelectedText());
                }
                dismiss();
                break;
        }
    }

    public interface DialogGrnderInterface {
        void onGrnderResult(String grnder);
    }
}

